<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Student_model extends CI_Model 
{

	public function get_student($openid)
	{
		$result = $this->db->get_where('user',array('openid'=>$openid))->result_array();
		return $result;
	}

	//绑定用户
	public function bind_user($data)
	{
		$this->db->insert('user',$data);
	}

	//检查该公众号是否已经绑定了
	public function check_exist($openid)
	{
		$result = $this->db->get_where('user',array('openid' => $openid))->result_array();
		return $result;
	}
	//删除数据
	public function del($openid){
		$this->db->where('openid',$openid);
		$this->db->delete('user');
	}


	public function comment_insert($data){
		$this->db->insert('comment',$data);
		return $this->db->insert_id();
	}

	public function getcomment(){
		return $this->db->get('comment')->result_array();
	}
		// 分页专用
	public function get_pagination($table,$perPage=null,$offset=null){
		$this->db->order_by('time','DESC');
		$query = $this->db->get($table,$perPage,$offset);
		return $query->result_array();
	}
}